package com.breaktian.network.api.base;

import android.content.Context;

import com.breaktian.network.http.Http;
import com.breaktian.network.http.HttpClient;
import com.breaktian.network.http.HttpConfig;
import com.breaktian.network.http.NetworkStatsInterceptor;

/**
 * Created by keke.tian on 2018/4/3.
 */

public class BaseApi {

    protected static boolean isDebug;
    protected static Context mContext;

    public BaseApi(){
        initHttp(mContext,isDebug);
    }

    /**
     * 初始化http
     * */
    public static void initHttp(Context context,boolean debug){
        mContext = context.getApplicationContext();
        isDebug = debug;
        HttpConfig config = HttpConfig.getInstance().with(mContext).debug(isDebug).addCommonHeader("Keep-Alive", "4");
        if (isDebug) {
            config.certificates().hostnameVerifier();
        } else {
            config.addInterceptor(new NetworkStatsInterceptor(mContext));
        }
        Http.init(config);
    }

}
